package com.cv.infra.controller.tus.file;

import com.cv.framework.common.pojo.Result;
import com.cv.infra.service.file.FileService;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 基础设施 - 平台文件控制层
 * 注意事项：Tus 上传至微服务需要配置跨域，否则无法上传成功
 *
 * @author Charles_XDXD
 */
@Tag(name = "基础设施 - 平台文件控制层")
@RestController
@RequestMapping("/infra/file")
public class FileController {

    @Resource
    private FileService fileService;

    @RequestMapping({"upload", "upload/*"})
    public Result<Void> uploadPost(HttpServletRequest request, HttpServletResponse response) {
        fileService.handleFileUpload(request, response);
        return Result.success();
    }

}
